package com.hunttown.mes.rpc.domain.enums.pay;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付/收款方式 1微信 2支付宝 3银行卡
 * created by wangjunfu on 2018/11/6
 */
public enum ReceiveWayEnum {
    WEIZHI(0, "未知 "),
    WEIXIN(1, "微信 "),
    ALIPAY(2, "支付宝"),
    USERCARD(3, "银行卡"),
    CASH(4, "现金"),
    TRANSFER(5, "银行转账"),
    RECORD(6, "记账"),
    ADVANCE(7, "预付款");

    private final int key;
    private final String value;

    ReceiveWayEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (ReceiveWayEnum temp : ReceiveWayEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (ReceiveWayEnum temp : ReceiveWayEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
